package com.weiyi.chat.presenter;

import com.weiyi.chat.api.IRegister;
import com.weiyi.chat.api.IResetPsw;
import com.weiyi.chat.common.MyStringCallBack;
import com.weiyi.chat.ui.activity.RegisterActivity;
import com.weiyi.chat.ui.activity.ResetPswActivity;
import com.weiyi.chat.utils.MyReusouce;
import com.zhy.http.okhttp.OkHttpUtils;

/**
 * Created by Lee on 2017/8/24 0024.
 */

public class ResetPswPresenter implements IResetPsw.presenter {


    private ResetPswActivity mView;

    public ResetPswPresenter(ResetPswActivity resetPswActivity) {
        mView = resetPswActivity;
    }


    @Override
    public void requsetResetPsw(String account, String old_psw, String new_psw) {
        OkHttpUtils.post()
                .url(MyReusouce.RESTER_PAW_URL)
                .addParams("account", account)
                .addParams("pass", old_psw)
                .addParams("newpass", new_psw)
                .build()
                .execute(new MyStringCallBack(mView) {
                    @Override
                    public void onRequestSucess(String response) {
                        mView.onResetSucess();
                    }

                    @Override
                    public void onRequstFail(String errorInfo) {
                        mView.showError(errorInfo);
                    }
                });
    }

    @Override
    public void loadingDatasFromCache() {

    }
}
